part of '../widget.dart';

class _TileTextButtonTheme extends InheritedTheme {
  _TileTextButtonTheme({
    required Brightness brightness,
    required super.child,
  })  : _brightness = brightness,
        _data = _buildThemeData(
          brightness: brightness,
        );

  final Brightness _brightness;
  final _TileTextButtonThemeData _data;

  static _TileTextButtonThemeData _buildThemeData({
    required Brightness brightness,
  }) {
    return switch (brightness) {
      _ => _TileTextButtonThemeData.dark(),
    };
  }

  static _TileTextButtonThemeData of(BuildContext context) {
    final inheritedTheme = context.dependOnInheritedWidgetOfExactType<_TileTextButtonTheme>()!;
    return inheritedTheme._data;
  }

  @override
  Widget wrap(BuildContext context, Widget child) {
    final ancestorTheme = context.findAncestorWidgetOfExactType<_TileTextButtonTheme>();

    if (identical(this, ancestorTheme)) {
      return child;
    }

    return _TileTextButtonTheme(
      brightness: _brightness,
      child: child,
    );
  }

  @override
  bool updateShouldNotify(_TileTextButtonTheme oldWidget) {
    return _brightness != oldWidget._brightness;
  }
}

class _TileTextButtonThemeData {
  const _TileTextButtonThemeData._internal({
    required this.textTheme,
  });

  factory _TileTextButtonThemeData.dark() {
    return _TileTextButtonThemeData._internal(
      textTheme: _TileTextButtonTextTheme.dark(),
    );
  }

  final _TileTextButtonTextTheme textTheme;
}
